<template>
  <div>
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      label-width="100px"
      label-position="left"
    >
      <el-form-item label="平台" prop="platform">
        <el-input disabled
          v-model="form.platform"
          placeholder=""
          maxlength="50"
        />
      </el-form-item>
      <el-form-item label="活动ID" prop="tp_id">
        <el-input disabled
          v-model="form.tp_id"
          placeholder=""
        />
      </el-form-item>
      <el-form-item label="昵称" prop="name">
        <el-input disabled
          v-model="form.name"
          placeholder=""
        />
      </el-form-item>
      <el-form-item prop="type">
        <el-select v-model="form.type" disabled placeholder="投诉类型">
          <el-option label="功能异常" :value="1" />
          <el-option label="产品建议" :value="2" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="模板分类" prop="template">
        <el-select
          clearable
          v-model="form.template"
          placeholder="请选择模板分类"
          style="width: 100%"
        >
          <el-option
            v-for="(item, index) in tempList"
            :key="index"
            :value="item.value"
            >{{ item.label }}</el-option
          >
        </el-select>
      </el-form-item> -->
      <el-form-item label="投诉内容" prop="msg">
        <el-input disabled
          v-model="form.msg"
          placeholder=""
          type="textarea"
          rows="3"
        />
      </el-form-item>
      <el-form-item label="备注" prop="desc">
        <el-input
          v-model="form.desc"
          placeholder=""
          type="textarea"
          rows="3"
        />
      </el-form-item>
      <!-- <el-form-item label="状态" prop="status">
        <el-radio-group v-model="form.status">
          <el-radio :label="1">正常</el-radio>
          <el-radio :label="2">禁用</el-radio>
        </el-radio-group>
      </el-form-item> -->
    </el-form>
    <div class="flexend">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="handleCloseAdd()">取 消</el-button>
    </div>
  </div>
</template>

<script>
import { isOverSize } from "@/utils/validate";
import { complainEdit } from '@/api/compain'
import { uploadPhoto } from "@/api/comm";
export default {
  data() {
    return {
      form: {},
      classList: [{ label: "抽奖专用模板", value: 1 }],
      tempList: [{ label: "抽奖活动", value: 1 }],
      // 表单校验
      rules: {
        // class: [
        //   { required: true, message: "分类名称不能为空", trigger: "blur" },
        // ],
        // imgurl: [
        //   { required: true, message: "预览图不能为空", trigger: "blur" },
        // ],
        // name: [
        //   { required: true, message: "模板名称不能为空", trigger: "blur" },
        // ],
        // template: [
        //   { required: true, message: "模板分类不能为空", trigger: "blur" },
        // ],
        // status: [{ required: true, message: "状态不能为空", trigger: "blur" }],
      },
    };
  },
  props:{
    row:{
      default:{}
    }
  },
  created(){
    if(this.row){
      this.form.id = this.row.id
      this.form.platform = this.row.task?this.row.task.tp_name:''
      this.form.tp_id = this.row.task?this.row.task.tp_id:''
      this.form.name = this.row.member?this.row.member.user_login:''
      this.form.type = this.row.type
      this.form.msg = this.row.msg
    }
  },
  methods: {

    handleCloseAdd(type) {
      this.$emit("close", type);
    },

    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          complainEdit({
            id:this.row.id,
            beizhu:this.form.desc
          }).then(res=>{
            this.$modal.msgSuccess("编辑成功");
            this.$emit('close',1)
          })
          // if (this.form.roleId != undefined) {
          //   this.form.menuIds = this.getMenuAllCheckedKeys();
          //   updateRole(this.form).then((response) => {
          //     this.$modal.msgSuccess("修改成功");
          //     this.open = false;
          //     this.getList();
          //   });
          // } else {
          //   this.form.menuIds = this.getMenuAllCheckedKeys();
          //   addRole(this.form).then((response) => {
          //     this.$modal.msgSuccess("新增成功");
          //     this.open = false;
          //     this.getList();
          //   });
          // }
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.inputbox {
  position: relative;
  padding: 0 20px;
  cursor: pointer;
}
.uploadinput {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  cursor: pointer;
}
.imginput {
  ::v-deep .el-input-group__append {
    padding: 0 !important;
  }
}
.imgurl {
  width: 200px;
  height: 80px;
}
</style>